home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Programmer Disk
/
The Programmer Disk (Microforum).iso
/
xpro
/
pascal3
/
pro16
/
paste.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1991-01-04
|
2KB
|
105 lines
program Past_File;
USES Rline;
TYPE
RFtester = Object(RFextended)
PROCEDURE CheckRFerror; virtual;
END;
PROCEDURE RFtester.CheckRFerror;
{ Displays some of the common errors, and waits for a keypress. }
BEGIN
IF (RFerror = 0)or(RFerror = $FFFF) then exit;
WriteLn(RFerrorString);
END;
const beep:char=#7;
inpbufsize=10*1024;
outpbufsize=40*1024;
var s1,s2,inp,inp1,inp2,outp:string;
inpf1,inpf2:rftester;
outpf:text;
inpb1,inpb2:array [1..inpbufsize] of char;
outpb:array[1..outpbufsize] of char;
procedure read_parameter;
var code:integer;
function create_file:boolean;
var err:boolean;
begin
assign(outpf,outp);
(*$i-*)
rewrite(outpf);
(*$i+*)
err:=(ioresult<>0);
if err then writeln('Error opening ',outp,'!',beep) else
settextbuf(outpf,outpb);
create_file:=not(err);
end;
function open_file:boolean;
var err:boolean;
begin
code:=pos('.',inp);
if code<>0 then begin
inp1:=copy(inp,1,code)+'LFT';
inp2:=copy(inp,1,code)+'RGT';
end else begin
inp1:=inp+'.LFT';
inp2:=inp+'.RGT';
end;
inpf1.Init(inp1, inpbufsize, inpb1); { try to open the file. }
inpf1.CheckRFerror;
err:=(inpf1.RFerror<>0);
if err then writeln('Error opening ',inp1,'!',beep) else begin
inpf2.Init(inp2, inpbufsize, inpb2); { try to open the file. }
inpf2.CheckRFerror;
err:=(inpf2.RFerror<>0);
if err then writeln('Error opening ',inp2,'!',beep)
end;
open_file:=not(Err);
end;
begin
inp:=paramstr(1);
while (not(open_file)) do begin
write('Input File Name (without extension) : ');
readln(inp);
end;
outp:=inp;
while(not(create_file)) do begin
write('Output File Name (with extension) : ');
readln(outp);
end;
end;
procedure screen;
begin
writeln('Paste File v 1.2 - (c) 1991 FD_SoftWare');
if paramcount<>1 then begin
writeln;
writeln('Usage:');
writeln(' PASTE [infile.ext]');
writeln;
writeln('Merge [file.LFT] and [file.RGT] in [file.ext]');
halt(1);
end;
writeln;
end;
begin
screen;
read_parameter;
while ((inpf1.RFerror=0) and (inpf2.RFerror=0)) do begin
inpf1.freadln(s1);
inpf2.freadln(s2);
writeln(outpf,s1+s2);
end;
inpf1.done;
inpf2.done;
close(outpf);
end.